package com.kenliang.netty.rpc.netty;

import com.google.common.reflect.Reflection;
import org.springframework.util.ReflectionUtils;

/**
 * @author KenLiang
 * @description:信息发送执行者
 * @date Created in 3:56 PM 2019/3/21.
 */
public class MessageSendExecutor {


    private RpcClientLoader rpcClientLoader =  RpcClientLoader.getInstance();


    private static class MessageSendExecutorHolder{
        private static final MessageSendExecutor  INSTANCE = new MessageSendExecutor();
    }
    private MessageSendExecutor(){

    }

    public static MessageSendExecutor getInstance(){
        return MessageSendExecutorHolder.INSTANCE;
    }



    //根据reference创建接口代理
    public <T> T  execute(Class<T> tClass){
        return Reflection.newProxy(tClass,new MessageSendProxy());
    }

    //创建到服务器的连接
    public void loadRpcClientLoader(String serverAddress){
        rpcClientLoader.load(serverAddress);

    }



}
